-
Notifications
You must be signed in to change notification settings - Fork 672
Claim existing IP addresses at startup with no race condition #2787
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One quick question about logging.
@@ -0,0 +1,54 @@ | |||
package main |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
9b56239
to
0831f81
Compare
doing it from the script Note we need to run weaver in the host pid namespace, so it can search for existing container IPs. Also now we are firing off sub-processes it's better to not be PID 1 so Linux doesn't expect us to reap zombies.
3552773
to
6ebf06e
Compare
6ebf06e
to
43ea755
Compare
The intention, per the comments, is that host1 should claim from host2. But host2 and host3 can carve up the space either way round. If host1 claims from host3 then there is a race whether anyone finds out about it. Adding a 'prime' on host2 ensures the space is all owned by host2 at that point.
43ea755
to
293abd9
Compare
ipam/allocator.go
Outdated
@@ -76,13 +76,20 @@ type Allocator struct { | |||
now func() time.Time | |||
} | |||
|
|||
type PreClaim struct { | |||
Ident string | |||
IsContainer bool |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
preClaims, err := findExistingAddresses(dockerCli, allContainerIDs, weavenet.WeaveBridgeName) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
// Now iterate over all containers to see if they have a network | ||
// namespace with an attached interface | ||
if dockerCli != nil { | ||
for _, cid := range containerIDs { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Fixes #2784
reclaim.go
is a re-implementation of thelaunch.sh
code to claim addresses in Go.We already had a
pendingClaims
list in IPAM, so we simply pre-populate this with entries for each existing address. The claims will be processed as soon as the ring is known.As it stands, this code is only good enough for
weave-kube
, not forweave launch
The code to find existing IPs works through the process table, and thus we do not have the Docker container ID. To resolve that I propose to add another loop to go through Docker container IDs if we have a Docker API connection.